package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle  string  `gorm:"type:varchar(100);not null;index;comment:商品名称"`
	GoodsPrice  float64 `gorm:"type:decimal(10,2);default:0.00;comment:商品价格"`
	Num         int     `gorm:"type:int;not null;comment:商品数量"`
	GoodsStock  int     `gorm:"type:int;not null;comment:商品库存"`
	GoodsCover  string  `gorm:"type:varchar(100);not null;comment:商品封面"`
	GoodsStatus int     `gorm:"type:tinyint(1);default:;comment:商品状态"`
}

func (g *Goods) Create() error {
	return Db.Create(&g).Error
}

func (g *Goods) Info(goodsId int) error {
	return Db.Where("id = ?", goodsId).First(&g).Error
}
